package com.pubinfo.passbook.api.controller.other;

import com.pubinfo.passbook.common.entity.TRabbitmqPersonConvert;
import com.pubinfo.passbook.common.entity.TWiteoffInstance;
import com.pubinfo.passbook.common.mapper.TSourcePassbookMapper;
import com.pubinfo.passbook.common.model.ruler.PayInformation;
import com.pubinfo.passbook.common.model.vo.base.JsonResult;
import com.pubinfo.passbook.common.model.vo.invoice.InvoiceObj;
import com.pubinfo.passbook.common.service.master.TRabbitmqPersonConvertService;
import com.pubinfo.passbook.common.service.master.TSystemRoleService;
import com.pubinfo.passbook.common.service.master.TWiteoffInstanceService;
import com.pubinfo.passbook.common.service.ruler.InformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.DocumentException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @author litiewang
 * @version 1.0
 * @date 2021/12/16 10:49
 */
@RestController
@RequestMapping(value = "passbookTest")
@Api(tags = "passbookTest")
@Slf4j
public class PassbookTestController {
  @Autowired
  InformationService informationService;
  @Autowired
  TSourcePassbookMapper passbookMapper;
  @Autowired
  TRabbitmqPersonConvertService convertService;
  @Autowired
  TWiteoffInstanceService tWiteoffInstanceService;
  @Autowired
  TSystemRoleService roleService;
  
  @PostMapping("insertPassbookWiteoff")
  @ApiOperation(value = "insertPassbookWiteoff")
  public Boolean insertPassbookWiteoff() throws DocumentException {
    
    List<String> invoiceList = new ArrayList<>();
    invoiceList.add("test");
    return passbookMapper.insertPassbookWiteoff("1453178110379180034", invoiceList);
  }
  
  @GetMapping("getPersonsByPersonOrgId/{acct}")
  @ApiOperation(value = "getPersonsByPersonOrgId")
  public JsonResult<List<TRabbitmqPersonConvert>> getPersonsByPersonOrgId(@PathVariable("acct") String acct) {
    return JsonResult.success(convertService.getPersonsByPersonOrgId(acct));
  }
  
  @GetMapping("findAcctIdByAcctId/{acct}")
  @ApiOperation(value = "获取报账人所属审核员账号")
  public JsonResult<String> findAcctIdByAcctId(@PathVariable("acct") String acct) {
    return JsonResult.success(roleService.findAcctByAcct(acct));
  }
  
  @PostMapping("informationFromPassbook")
  @ApiOperation(value = "获取票据累加数据")
  public JsonResult<PayInformation> informationFromPassbook(@RequestBody List<String> ids) {
    return JsonResult.success(informationService.informationFromPassbook(ids));
  }
  
  @PostMapping("invoiceInfo")
  @ApiOperation(value = "发票信息")
  public JsonResult<Boolean> invoiceInfo(@RequestBody InvoiceObj invoice) {
    return JsonResult.success(true);
  }
  
  @GetMapping("getTwiteoffInstanceByOtherSystemMainId/{id}")
  @ApiOperation(value = "报账单信息")
  public JsonResult<TWiteoffInstance> getTwiteoffInstanceByOtherSystemMainId(@PathVariable("id") String id) {
    return JsonResult.success(tWiteoffInstanceService.getTwiteoffInstanceByOtherSystemMainId(id));
  }
  
}
